package zxs.sino.elite.hub.controller;

import java.util.Arrays;
import java.util.Map;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zxs.sino.elite.hub.model.app.ChatRoomMemberEntity;
import zxs.sino.elite.hub.service.app.ChatRoomMemberService;
import zxs.sino.elite.hub.utils.PageUtil;
import zxs.sino.elite.hub.utils.R;



/**
 * 聊天室成员表
 *
 * @author zhang
 * @email 15824760766@163.com
 * @date 2025-09-02 20:23:52
 */
@RestController
@RequestMapping("chatroommember")
@RequiredArgsConstructor
public class ChatRoomMemberController {

    private final  ChatRoomMemberService chatRoomMemberService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtil page = chatRoomMemberService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{memberId}")
    public R info(@PathVariable("memberId") Long memberId){
		ChatRoomMemberEntity chatRoomMember = chatRoomMemberService.getById(memberId);

        return R.ok().put("chatRoomMember", chatRoomMember);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ChatRoomMemberEntity chatRoomMember){
		chatRoomMemberService.save(chatRoomMember);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ChatRoomMemberEntity chatRoomMember){
		chatRoomMemberService.updateById(chatRoomMember);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] memberIds){
		chatRoomMemberService.removeByIds(Arrays.asList(memberIds));

        return R.ok();
    }

}
